<template>
  <div class="transfer_confirm_page">
    <div class="type_box">
      <van-cell title="转账类型" :value="transferType[form.type].name" />
      <van-cell v-if="form.type === '02'" title="到账时间" :value="form.date" />
    </div>
    <div class="receive_payment_box">
      <van-cell title="收款人账号" :value="form.payeeAcNo" />
      <van-cell title="收款人名称" :value="form.payeeName" />
      <template v-if="form.type === '02'">
        <van-cell title="是否向个人转账" :value="form.isTransferToPer" />
        <van-cell title="开户行名称" :value="form.bankName" />
      </template>
    </div>
    <div class="transfer_payment_box">
      <van-cell title="付款账号" :value="form.payerAcNo" />
      <van-cell title="转账金额" :value="form.amount" />
      <van-cell title="转账用途" :value="form.use" />
      <van-cell title="备注" :value="form.remark" />
    </div>
    <div class="transfer_payee_box">
      <van-cell title="是否预约" :value="form.isAppointment">
        <template #default>{{isAppointment[form.isAppointment]}}</template>
      </van-cell>
      <van-cell v-if="!parseInt(form.isAppointment)" title="预约日期" :value="form.appointmentDate" />
    </div>
    <div class="next_box">
      <van-button type="info" @click="submitAccountTran" block>提交</van-button>
    </div>
  </div>
</template>

<script>
import {
  Toast,
} from 'vant';
import Constants from '@/libs/constant';
import { territoryRMBInnerTransfer, territoryRMBOuterTransfer } from '@/libs/api';

export default {
  components: {
    [Toast.name]: Toast,
  },
  data() {
    return {
      transferType: Constants.transferType,
      form: this.$store.state.formData || {},
      isAppointment: {
        0: '预约',
        1: '未预约'
      }
    };
  },
  methods: {
    submitAccountTran() {
      this.form.cstNo = this.$store.state.loginUser.cichno;
      this.form.hostNo = this.$store.state.loginUser.cino;
      this.form.operNo = this.$store.state.loginUser.userId;
      this.form.operName = this.$store.state.loginUser.userName;
      this.form.isAssignAccount = '1';
      this.form.menuId = '99';
      console.log(this.form.type);
      if (this.form.type === 0) {
        console.log('*******行内转账*******');
        territoryRMBInnerTransfer(this, this.form).then((res) => {
          if (res.retCode === 'CIP0000000') {
            console.log('*******限额信息*******');
            console.log(res);
            console.log('**************');
            Toast('制单成功');
          }
        });
      } else {
        console.log('*******行外转账*******');
        territoryRMBOuterTransfer(this, this.form).then((res) => {
          if (res.retCode === 'CIP0000000') {
            console.log('*******限额信息*******');
            console.log(res);
            console.log('**************');
            Toast('制单成功');
          }
        });
      }
    },
  },
  mounted() {
    console.log(this.$route.params);
    console.log(this.$route);
    console.log(this.$store.state.formData);
  }
};
</script>

<style lang="less">
.transfer_confirm_page{
  background-color: #EFEFEF;
  height: calc(100vh - 46PX);
  .type_box{
    padding-top: 1vh;
  }
  .receive_payment_box {
    padding-top: 1vh;
  }
  .transfer_payment_box {
    padding-top: 1vh;
  }
  .transfer_payee_box {
    padding-top: 1vh;
  }
  .other_box {
    padding-top: 1vh;
  }
  .next_box{
    padding: 1.2rem 0.8rem 0;
  }
}
</style>
